package org.nimi317.web_gis.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.nimi317.web_gis.entity.Role;

import java.util.List;

/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 * @author nimi317
 * @since 2024-04-13
 */
public interface RoleMapper extends BaseMapper<Role> {
    /**
     * 不可删除
     * @param userId 用户id
     * @return 返回值
     */
    @Select("select * from role a inner join u_r b on a.id = b.r where b.u = #{id}")
    @Results(value = {
            @Result(column = "id", property = "id"),
            @Result(column = "id", property = "permissions", many = @Many(select = "org.nimi317.web_gis.dao.PermissionMapper.getPermissionsByRoleId"))
    })
    List<Role> getRoleVoByUserId(@Param("id") Long userId);
}
